package com.first.agent.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.first.agent.common.R;
import com.first.agent.service.UserManagementService;
import com.first.agent.service.impl.UserManagementServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

@WebServlet("/system/userManagementFindRoleServlet")
public class UserManagementFindRoleServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        UserManagementService userManagementService = new UserManagementServiceImpl();
        List<Map<String, Object>> allRole = userManagementService.findAllRole();
        R r = new R();
        r.setData(allRole);
        //对页面进行数据响应
        resp.setContentType("application/json;charset=utf-8");
        PrintWriter pw=resp.getWriter();
        pw.write(JSONObject.toJSONString(r));
        pw.flush();
        pw.close();
    }
}
